package edu.usc.csci578.algorithm;

import java.io.OutputStream;
import java.io.PrintWriter;

import edu.usc.csci578.model.Cluster;
import edu.usc.csci578.model.ClusterEdge;

public class TrangleDependenceAlgorithm extends AbstracAlgorithm {

	@Override
	public SolutionSet execute(OutputStream stream) throws Exception {
		SolutionSet ss = new SolutionSet();

		PrintWriter pw = new PrintWriter(stream);
		pw.println("Trangle Detect Start!");

		for (Cluster c : mm.getAllClusters()) {
			for (ClusterEdge ce : c.getEdgesAll()) {
				if (ce.getSrc().isSpec() && ce.getTgt().isSpec()) {
					for (Cluster p : mm.getAllClusters()) {
						if (p.containsIn(ce.getSrc())
								&& p.containsOut(ce.getTgt()) && p.isIndep()) {
							pw.println(ce.getSrc().getName()
									+ "OOXXOOXX" + ce.getTgt().getName());
						}
					}
				}
			}
		}

		pw.println("Trangle Reference Detect End!");
		return ss;
	}

	@Override
	public String getDescription() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String getName() {
		// TODO Auto-generated method stub
		return null;
	}

}
